package com.lz.hotel_java.mapper;

import com.lz.hotel_java.entity.Booking;
import org.apache.ibatis.annotations.*;
import java.util.List;

@Mapper
public interface BookingMapper {
    @Insert("INSERT INTO Booking(BookingTime, CustomerID, RoomID, Status) VALUES(#{bookingTime}, #{customerID}, #{roomID}, #{status})")
    @Options(useGeneratedKeys = true, keyProperty = "bookingID")
    int insert(Booking booking);

    @Select("SELECT * FROM Booking WHERE Status = N'已预订'")
    List<Booking> selectBooked();
    @Select("SELECT * FROM Booking")
    List<Booking> selectAll();
    @Update("UPDATE Booking SET Status = #{status} WHERE BookingID = #{bookingId}")
    int updateStatus(@Param("bookingId") Integer bookingID, @Param("status") String status);

    @Update("UPDATE Booking SET Status = #{status}, CheckInTime = GETDATE() WHERE BookingID = #{bookingId}")
    int checkIn(@Param("bookingId") Integer bookingID, @Param("status") String status);

    @Update("UPDATE Booking SET Status = #{status}, CheckOutTime = GETDATE() WHERE BookingID = #{bookingId}")
    int checkOut(@Param("bookingId") Integer bookingID, @Param("status") String status);
}

